package previous.Test_0324;

import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Bridge_Blue {
    //斐波那契循环数
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n= (int)1e7;
        int ret=0;

        for(int i=1000;i<=n;i++) {
            String string=String.valueOf(i);
            int count= string.length();
            int[] a=new int[count+1];
            for (int j = 0; j < count; j++) {
                a[j]=string.charAt(j)-'0';
            }
            if(t(i,a,count)) {
                ret=Math.max(ret,i);
            }
        }
        System.out.println(ret);
        scan.close();
    }
    public static boolean t(int x,int[] a,int count) {
      long sum=0;
        while(true) {
            sum=0;
            for (int j = 1; j <= count; j++) {
                sum+=a[j];
            }
            for (int i = 0; i < count; i++) {
                a[i]=a[i+1];
            }
            if(sum>=x) break;
        }
        return x==sum;
    }
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n=(int)1e7;
        int ret=0;

        for(int i=0;i<=n;i++)
        {
            ret=Math.max(func(i),ret);
        }

        System.out.println(ret);
        scan.close();
    }
    public static int func(int n){
        String str=String.valueOf(n);
        int x=str.length();
        long[] num=new long[x+1];
        for(int i=1;i<=x;i++)
        {
            num[i]=(long)str.charAt(i-1)-'0';
        }
        long sum=0;
        while(true){
            sum=0;
            for(int i=1;i<=x;i++)
            {
                sum+=num[i];
            }
            for(int i=1;i<x;i++)
            {
                num[i]=num[i+1];
            }
            num[x]=sum;
            if(sum>=n)break;
        }
        if(sum==n)return n;
        else return -1;
    }
    //时间显示
    public static void main4(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        long time=scan.nextLong();
        //将毫秒转化为秒
        long seconds=time/1000;
        //将秒转化为小时
        long hour=(seconds/3600)%24;
        //分
        long cen=(seconds%3600)/60;
        //剩下的秒
        long t=seconds%60;
        System.out.printf("%02d:%02d:%02d",hour,cen,t);

        scan.close();
    }


}
